﻿using KC.Common;
using KC.Framework.Base;
using KC.Framework.Tenant;
using KC.DTO.Core;

namespace KC.Service.Core.WebApiService.Business
{
    public class WorkFlowBusiApiService : IdSrvOAuth2ClientRequestBase
    {
        private const string ServiceName = "KC.Service.Core.WebApiService.WorkFlowBusiApiService";

        public WorkFlowBusiApiService(
            Tenant tenant, 
            System.Net.Http.IHttpClientFactory httpClient,
            Microsoft.Extensions.Logging.ILogger<WorkFlowBusiApiService> logger)
            : base(TenantConstant.DbaTenantApiAccessInfo, httpClient, logger)
        {
        }
        /// <summary>
        /// 审批中心更新业务流程
        /// </summary>
        /// <param name="url">回调URL</param>
        /// <param name="busiBase">更新的数据对象</param>
        /// <returns></returns>
        public ServiceResult<string> UpdateBusinessFlowStat(string url,FlowBusiBase busiBase)
        {
            var postData = SerializeHelper.ToJson(busiBase);
            ServiceResult<string> result = null;
            WebSendPost<ServiceResult<string>>(
                ServiceName + ".UpdateBusinessFlowStat",
                FlowApiServerUrl + url,
                ApplicationConstant.FlowScope,
                postData,
                callback =>
                {
                    result = callback;
                },
                (httpStatusCode, errorMessage) =>
                {
                    result = new ServiceResult<string>(ServiceResultType.Error, httpStatusCode, errorMessage);
                },
                true);

            return result;
        }
    }
}
